package com.gitee.wsl.mathematics.geometry.d2.contour.adjust.extensions


import com.gitee.wsl.mathematics.geometry.d2.contour.adjust.ContourAdjusterVertex
import com.gitee.wsl.mathematics.geometry.d2.contour.adjust.ContourVertex
import com.gitee.wsl.mathematics.vector.ext.dot
import kotlin.math.acos

val ContourVertex.angleBetweenTangents: Double
    get() {
        return if (tangentIn != null && tangentOut != null) {
            acos(tangentIn!!.normalized.dot(tangentOut!!.normalized)).toDouble()
        } else {
            0.0
        }
    }

val ContourAdjusterVertex.angleBetweenTangents: Double
    get() {
        return ContourVertex(contourAdjuster.contour, segmentIndex()).angleBetweenTangents
    }